﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

/*********************************************************
 * 命名空间 MDT.VirtualSoftPlatform.Common.Resualt
 * 接口名称 DateMessage
 * 开发人员：-nhy
 * 创建时间：2022/6/27 14:06:22
 * 描述说明：
 * 更改历史：
 * 
 * *******************************************************/
namespace Simple.Tools
{
    /// <summary>
    /// 
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class DataMessage<T> : BaseMessage
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="code"></param>
        /// <param name="status"></param>
        /// <param name="Data"></param>
        public DataMessage(string msg, int code, bool status, T Data)
            : base(msg, code, status)
        {
            data = Data;
        }
        /// <summary>
        /// 
        /// </summary>
        public T data { get; set; }
        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public T GetData<T>() where T : class
        {
            //将data 转换为T然后将引用返回转换失败将返回null
            return data as T;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public int GetInt32()
        {
            int.TryParse(data.ToString(), out int res);
            return res;
        }
    }
}
